<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // extends
        function Animal(name,age,gender){
            this.name = name;
            this.age = age;
            this.gender = gender;
        }
        Animal.prototype.eat = function(){
            console.log("吃");
        }
        // let a = new Animal("张三",18,'男');
        // console.log(a);

        function Dog(){}

        //原型继承
        Dog.prototype = new Animal();

        let d = new Dog();
        d.name = "阿黄"
        d.age = 18;
        d.gender = "男"
        d.eat();
        console.log(d);
    </script>
</body>
</html>